

// 我的订单页面 陈俊俊
<template>
  <div class="body">
    <div class="top">
      <router-link to="/home">
        <van-icon class="icon" name="wap-home-o" />
      </router-link>
      <span>我的订单</span>
    </div>

    <ul class="content">
      <li>
        <router-link to="/order/detail">
          <span class="Highlight">全部</span>
        </router-link>
      </li>
      <li>
        <router-link to="/order/shared">
          <span>待分享</span>
        </router-link>
      </li>
      <li>
        <router-link to="/order/pay">
          <span>待付款</span>
        </router-link>
      </li>
      <li>
        <router-link to="/order/consignment">
          <span>待发货</span>
        </router-link>
      </li>
      <li>
        <router-link to="/order/goods">
          <span>待收货</span>
        </router-link>
      </li>
    </ul>

    <van-loading v-if="istrue" type="spinner" class="center" size="40px" />
    <div v-else>
      <div class="rule" v-for="(item,index) in list" :key="index">
        <router-link :to="`/order/detail/${item.orderId}`">
          <ul class="imgs" v-for="(ite,inde) in item.carts" :key="inde">
            <li>
              <img :src="ite.imgUrl" alt />
              <div>
                <div>{{ite.masterName}}</div>

                <div>
                  <span>&yen;{{ite.price/100}}</span>
                </div>
              </div>
            </li>

            <van-icon class="icon1" name="arrow" />
          </ul>
        </router-link>

        <div class="pay">
          <div>
            共
            <span>{{ item.carts | addNum}}</span>件商品
          </div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          <div class="money">
            实付&yen;
            <span>{{item.totalMoney?item.totalMoney:0}}</span>
            元
          </div>
        </div>

        <div class="agin">
          <div>已取消</div>
          <div>
            <!-- <router-link to="/home"> -->
            <span @click="again(item)">重新购买</span>
            <!-- </router-link> -->
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  data() {
    return {
      list: [],
      active: "home",
      istrue: true
    };
  },
  methods: {
    getList() {
      let url = "/order/all";
      this.$axios
        .get(url)
        .then(res => {
          console.log("res", res);
          this.list = res.list;

          this.istrue = false;
        })
        .catch(err => {
          console.log("err", err);
        });
    },
    again(item) {
      let productId = item.carts[0].productId;
      let buyNum = item.carts[0].buyNum;
      let url = "/cart/add";
      let data = { productId, buyNum };
      this.$axios
        .post(url, data)
        .then(res => {
          this.$router.push(`/order/submit/${productId}/${1}`);
        })
        .catch(err => {
          console.log("err", err);
        });
    }
  },
  created() {
    this.getList();
  }
};
</script>
<style lang="less" scoped>
.center {
  height: 100vh;
  width: 100vw;
  text-align: center;
  position: fixed;
  top: 30%;
}
.Highlight {
  position: relative;
  color: #c03131;
}
.Highlight::after {
  content: "";
  width: 100%;
  height: 2px;
  position: absolute;
  top: 32px;
  left: 0px;
  background-color: #c03131;
}
* {
  margin: 0;
  padding: 0;
}
.body {
  background-color: #f4f4f4;
  // height: 100vh;
}
.top {
  background-color: #fff;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  text-align: center;
  height: 44px;
  line-height: 44px;
  z-index: 2;
  .icon {
    position: absolute;
    font-size: 22px;
    left: 10px;
    top: 9px;
  }
  span {
    margin-left: -22px;
    font-weight: 700px;
    color: #2e2f30;
    font-size: 17px;
    font-family: Microsoft YaHei, Tahoma, Helvetica, Arial, sans-serif;
  }
}
.content::-webkit-scrollbar {
  overflow-x: hidden;
  display: none;
}
.content {
  margin-top: 44px;
  background-color: #fff;
  display: flex;
  white-space: nowrap;
  border: 1px solid rgba(0, 0, 0, 0);
  border-top-color: #f6f6f6;
  border-bottom-color: #f6f6f6;
  font-size: 14px;
  overflow-x: scroll;

  text-overflow: ellipsis;
  li {
    margin: 0 20px;
    height: 49px;
    line-height: 49px;
    color: #797d82;
  }
}
.rule {
  background-color: #fff;
  margin-bottom: 10px;
  .imgs {
    position: relative;
    display: flex;
    padding: 15px;
    li {
      margin-right: 10px;
      display: flex;
      img {
        width: 60px;
        height: 60px;
      }
      div {
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        margin-left: 10px;

        div:nth-child(1) {
          display: flex;
          flex-direction: row;
          line-height: 22px;
          font-size: 15px;
        }
        div:nth-child(2) {
          display: flex;
          flex-direction: row;
          height: 22px;
          line-height: 22px;
        }
      }
    }
    .icon1 {
      position: absolute;
      right: 20px;
      top: 40px;
    }
  }
  .pay {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    border: 1px solid rgba(0, 0, 0, 0);
    border-top-color: #f6f6f6;
    border-bottom-color: #f6f6f6;
    height: 40px;
    line-height: 40px;
    padding-right: 20px;
    font-size: 15px;
  }
  .money span {
    color: #c34244;
  }
  .agin {
    display: flex;
    justify-content: space-between;
    padding: 10px 20px 10px 10px;
    font-size: 15px;
    div:nth-child(1) {
      color: #c3c5ca;
      height: 30px;
      line-height: 30px;
    }
    div:nth-child(2) {
      span {
        display: block;
        border: 1px solid black;
        border-radius: 3px;
        padding: 8px 20px;
        color: #454647;
        font-size: 15px;
        height: 30px;
      }
    }
  }
}
</style>